<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>闭包的使用</title>
</head>
<body>
    <input type="button" id="add" value="按钮">
    <p id="show">

    </p>
    <script>
        let addBtn = document.getElementById("add");
        let show = document.getElementById("show");
        let count = 0;
        addBtn.onclick = function(){
            show.innerHTML = ++count;
        }

        setInterval(function(){
            show.innerHTML = ++count;
        },500);
    </script>
</body>
</html>